package com.chanyachting.emall.action.recruitmentinformation;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.chanyachting.emall.domain.Joblist;
import com.chanyachting.emall.service.RecruitmentinformationService;
import com.chanyachting.emall.serviceImpl.RecruitmentinformationServiceImpl;
import com.chanyachting.emall.util.RequestUtil;

public class DeleteJobListAction extends Action {

	//删除招聘岗位
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		RequestUtil ru=new RequestUtil(request);
		
		int riId=Integer.parseInt(ru.getParameter("riId", "0"));
		
		int jobid=Integer.parseInt(ru.getParameter("jobid", "0"));
		
		Joblist job=new Joblist();
		
		if(riId!=0){
			
			//如果有招聘信息编号
			job.setId(jobid);
			
			job.setJobname("");
			job.setJobtype("");
			job.setJobpay("");
			job.setCreatedate("");
			job.setJobnumber("");
			
			RecruitmentinformationService ris=new RecruitmentinformationServiceImpl();
			
			try {
				
				ris.deleteJobList(job);
				
			} catch (Exception e) {
				
				e.printStackTrace();
			}
			
			
			
			
		}else{
			
			//如果没有招聘信息对象编号 ,删除session中的岗位信息

			List jobList=(List)ru.getSessionObject(RecruitmentinformationService.JOBLLIST_IN_SESSION, new ArrayList());
			
			jobList.remove(jobid);
		
		}

		return mapping.findForward("");
	}
	
	

}
